package com.example.mam.util;


import com.sicerora.mt5managerapi64j.entity.OutInt;
import com.sicerora.mt5managerapi64j.factory.ManagerAPIFactory;
import com.sicerora.mt5managerapi64j.manager.IMTAdminAPI;
import com.sicerora.mt5managerapi64j.manager.IMTManagerAPI;

public class ManagerAPIUtils {
    static {
        System.load("C:/Users/wl/Desktop/MT5APIManager64J/MT5APIManager64J.dll");
    }

    /**
     * 创建ManagerAPIFactory对象
     *
     * @param path MT5APIManager64.dll 所在的文件夹
     * @return D:/MT5APIManager64/
     */
    public static ManagerAPIFactory getManagerAPIFactory(String path) {
        ManagerAPIFactory managerAPIFactory = new ManagerAPIFactory();
        int resCode = managerAPIFactory.initialize("D:/MT5APIManager64/");
        System.out.println("创建ManagerAPIFactory对象:"+resCode);
        return managerAPIFactory;
    }

    /**
     * 获取版本
     *
     * @param managerAPIFactory
     * @return OutInt
     */
    public static OutInt getVersion(ManagerAPIFactory managerAPIFactory) {
        OutInt version = new OutInt();
        managerAPIFactory.version(version);
        return version;
    }

    /**
     * 创建IMTManagerAPI
     *
     * @param managerAPIFactory
     * @param version
     * @param dataPath          数据文件夹   D:/apispace/managerbbb
     * @return
     */
    public static IMTManagerAPI getIMTManagerAPI(ManagerAPIFactory managerAPIFactory, OutInt version, String dataPath) {
        IMTManagerAPI imtManagerAPI = new IMTManagerAPI();
        managerAPIFactory.createManager(version.getData(), "D:/apispace/managerbbb", imtManagerAPI);
        return imtManagerAPI;
    }

    /**
     * 创建IMTAdminAPI
     *
     * @param managerAPIFactory
     * @param version           版本
     * @param dataPath          数据文件路径    D:/apispace/admin
     * @return
     */
    public static IMTAdminAPI getIMTAdminAPI(ManagerAPIFactory managerAPIFactory, OutInt version, String dataPath) {
        IMTAdminAPI imtAdminAPI = new IMTAdminAPI();
        managerAPIFactory.createAdmin(version.getData(), "D:/apispace/admin", imtAdminAPI);
        return imtAdminAPI;
    }


}




